package com.muyu.system.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.system.domain.DanmoUserShop;
import com.muyu.system.service.IDanmoUserShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 商品关注Controller
 *
 * @author yangle
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/shop")
public class DanmoUserShopController extends BaseController
{
    @Autowired
    private IDanmoUserShopService danmoUserShopService;

    /**
     * 查询商品关注列表
     */
//    @RequiresPermissions("system:shop:list")
    @GetMapping("/list")
    public Result list(DanmoUserShop danmoUserShop)
    {
        PageHelper.startPage(danmoUserShop.getPageNum(), danmoUserShop.getPageSize());
        List<DanmoUserShop> list = danmoUserShopService.selectDanmoUserShopList(danmoUserShop);
        PageInfo<DanmoUserShop> danmoMarketProductsPageInfo = new PageInfo<>(list);
        return Result.success(danmoMarketProductsPageInfo);
    }

    /**
     * 导出商品关注列表
     */
//    @RequiresPermissions("system:shop:export")
    @Log(title = "商品关注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoUserShop danmoUserShop)
    {
        List<DanmoUserShop> list = danmoUserShopService.selectDanmoUserShopList(danmoUserShop);
        ExcelUtil<DanmoUserShop> util = new ExcelUtil<DanmoUserShop>(DanmoUserShop.class);
        util.exportExcel(response, list, "商品关注数据");
    }

    /**
     * 获取商品关注详细信息
     */
//    @RequiresPermissions("system:shop:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoUserShopService.selectDanmoUserShopById(id));
    }

    /**
     * 新增商品关注
     */
//    @RequiresPermissions("system:shop:add")
    @Log(title = "商品关注", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoUserShop danmoUserShop)
    {
        return toAjax(danmoUserShopService.insertDanmoUserShop(danmoUserShop));
    }

    /**
     * 修改商品关注
     */
//    @RequiresPermissions("system:shop:edit")
    @Log(title = "商品关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoUserShop danmoUserShop)
    {
        return toAjax(danmoUserShopService.updateDanmoUserShop(danmoUserShop));
    }

    /**
     * 删除商品关注
     */
//    @RequiresPermissions("system:shop:remove")
    @Log(title = "商品关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoUserShopService.deleteDanmoUserShopByIds(ids));
    }



}
